/*
 * LoggerUtil.java
 */

package xq.util;

import org.apache.log4j.Logger;

/**
 * 
 * @author ThorntonRP
 */
public class LoggerUtil {

	/**
	 * Obtains a logger for the calling class.
	 * @return 
	 */
	public static Logger getClassLogger() {
		StackTraceElement[] stack = Thread.currentThread().getStackTrace();
		StackTraceElement ste = null;
		int index = 0;
		do {
			if (stack[index].getClassName().equals(LoggerUtil.class.getName())) {
				ste = stack[index + 1];
			} else {
				index++;
			}
		} while (ste == null);
		return Logger.getLogger(ste.getClassName());
	}

	private LoggerUtil() {
	}
}
